//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "VegaStressedBlackScholesProcess.h"
using namespace Cephei::QL::Experimental::Processes;
#include <gen/QL/Quote.h>
#include <gen/QL/Termstructures/YieldTermStructure.h>
#include <gen/QL/Termstructures/Volatility/Equityfx/BlackVolTermStructure.h>
#include <gen/QL/Termstructures/Volatility/Equityfx/LocalVolTermStructure.h>
#include <gen/QL/Math/Array.h>
#include <gen/QL/Processes/GeneralizedBlackScholesProcess.h>
using namespace Cephei::QL;
using namespace Cephei::QL::Termstructures;
using namespace Cephei::QL::Termstructures::Volatility::Equityfx;
using namespace Cephei::QL::Math;
using namespace Cephei::QL::Processes;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::CVegaStressedBlackScholesProcess (Cephei::QL::IQuote^ x0, Cephei::QL::Termstructures::IYieldTermStructure^ dividendTS, Cephei::QL::Termstructures::IYieldTermStructure^ riskFreeTS, Cephei::QL::Termstructures::Volatility::Equityfx::IBlackVolTermStructure^ blackVolTS, Microsoft::FSharp::Core::FSharpOption<Double>^ lowerTimeBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ upperTimeBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ lowerAssetBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ upperAssetBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ stressLevel) : CGeneralizedBlackScholesProcess(CVegaStressedBlackScholesProcess::typeid)
{
    CQuote^ _Cx0;
    CYieldTermStructure^ _CdividendTS;
    CYieldTermStructure^ _CriskFreeTS;
    CBlackVolTermStructure^ _CblackVolTS;
    try
    {
#ifdef HANDLE
        _phVegaStressedBlackScholesProcess = NULL;
#endif
        _Cx0 = safe_cast<CQuote^> (x0);
        _Cx0->Lock();
        Handle<QuantLib::Quote>& _x0 = static_cast<Handle<QuantLib::Quote>&> (_Cx0->GetHandle ()); 
        _CdividendTS = safe_cast<CYieldTermStructure^> (dividendTS);
        _CdividendTS->Lock();
        Handle<QuantLib::YieldTermStructure>& _dividendTS = static_cast<Handle<QuantLib::YieldTermStructure>&> (_CdividendTS->GetHandle ()); 
        _CriskFreeTS = safe_cast<CYieldTermStructure^> (riskFreeTS);
        _CriskFreeTS->Lock();
        Handle<QuantLib::YieldTermStructure>& _riskFreeTS = static_cast<Handle<QuantLib::YieldTermStructure>&> (_CriskFreeTS->GetHandle ()); 
        _CblackVolTS = safe_cast<CBlackVolTermStructure^> (blackVolTS);
        _CblackVolTS->Lock();
        Handle<QuantLib::BlackVolTermStructure>& _blackVolTS = static_cast<Handle<QuantLib::BlackVolTermStructure>&> (_CblackVolTS->GetHandle ()); 
        QuantLib::Time _lowerTimeBorderForStressTest = 
            (Microsoft::FSharp::Core::FSharpOption<Double>::IsSome::get (lowerTimeBorderForStressTest) ? (QuantLib::Time)ValueHelper::Convert (lowerTimeBorderForStressTest->Value) : 0); //4
        QuantLib::Time _upperTimeBorderForStressTest = 
            (Microsoft::FSharp::Core::FSharpOption<Double>::IsSome::get (upperTimeBorderForStressTest) ? (QuantLib::Time)ValueHelper::Convert (upperTimeBorderForStressTest->Value) : 1000000); //4
        QuantLib::Real _lowerAssetBorderForStressTest = 
            (Microsoft::FSharp::Core::FSharpOption<Double>::IsSome::get (lowerAssetBorderForStressTest) ? (QuantLib::Real)ValueHelper::Convert (lowerAssetBorderForStressTest->Value) : 0); //4
        QuantLib::Real _upperAssetBorderForStressTest = 
            (Microsoft::FSharp::Core::FSharpOption<Double>::IsSome::get (upperAssetBorderForStressTest) ? (QuantLib::Real)ValueHelper::Convert (upperAssetBorderForStressTest->Value) : 1000000); //4
        QuantLib::Real _stressLevel = 
            (Microsoft::FSharp::Core::FSharpOption<Double>::IsSome::get (stressLevel) ? (QuantLib::Real)ValueHelper::Convert (stressLevel->Value) : 0); //4
        _ppVegaStressedBlackScholesProcess = new boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess> (new QuantLib::VegaStressedBlackScholesProcess ( _x0,  _dividendTS,  _riskFreeTS,  _blackVolTS,  _lowerTimeBorderForStressTest,  _upperTimeBorderForStressTest,  _lowerAssetBorderForStressTest,  _upperAssetBorderForStressTest,  _stressLevel ));
        SetGeneralizedBlackScholesProcess (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppVegaStressedBlackScholesProcess));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cx0 != nullptr) _Cx0->Unlock();
        if (_CdividendTS != nullptr) _CdividendTS->Unlock();
        if (_CriskFreeTS != nullptr) _CriskFreeTS->Unlock();
        if (_CblackVolTS != nullptr) _CblackVolTS->Unlock();
    }
}
Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::CVegaStressedBlackScholesProcess (boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess>& childNative, Object^ owner) : CGeneralizedBlackScholesProcess(CVegaStressedBlackScholesProcess::typeid)
{
#ifdef HANDLE
	_phVegaStressedBlackScholesProcess = NULL;
#endif
	_ppVegaStressedBlackScholesProcess = &childNative;
    _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppVegaStressedBlackScholesProcess));
}
Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::CVegaStressedBlackScholesProcess (QuantLib::VegaStressedBlackScholesProcess& childNative, Object^ owner) : CGeneralizedBlackScholesProcess(CVegaStressedBlackScholesProcess::typeid)
{
#ifdef HANDLE
	_phVegaStressedBlackScholesProcess = NULL;
#endif
	_ppVegaStressedBlackScholesProcess = new boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess> (&childNative);
    _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppVegaStressedBlackScholesProcess));
    _VegaStressedBlackScholesProcessOwner = owner;
    _GeneralizedBlackScholesProcessOwner = owner;
}

Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::CVegaStressedBlackScholesProcess (CVegaStressedBlackScholesProcess^ copy) : CGeneralizedBlackScholesProcess(CVegaStressedBlackScholesProcess::typeid)
{
#ifdef HANDLE
	_phVegaStressedBlackScholesProcess = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppVegaStressedBlackScholesProcess = new boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess> (copy->GetShared());
        _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppVegaStressedBlackScholesProcess));
    }
}
Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::CVegaStressedBlackScholesProcess (PLATFORM::Type^ t) : CGeneralizedBlackScholesProcess(CVegaStressedBlackScholesProcess::typeid)
{
#ifdef HANDLE
	_phVegaStressedBlackScholesProcess = NULL;
#endif
	if (!t->IsSubclassOf(CVegaStressedBlackScholesProcess::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::CVegaStressedBlackScholesProcess (QuantLib::Handle<QuantLib::VegaStressedBlackScholesProcess>& childNative, Object^ owner)  : CGeneralizedBlackScholesProcess(CVegaStressedBlackScholesProcess::typeid)
{
	_phVegaStressedBlackScholesProcess = &childNative;
	_ppVegaStressedBlackScholesProcess = &static_cast<boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess>>(childNative.currentLink());
    _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppVegaStressedBlackScholesProcess));
    _VegaStressedBlackScholesProcessOwner = owner;
}
Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::CVegaStressedBlackScholesProcess (QuantLib::Handle<QuantLib::VegaStressedBlackScholesProcess> childNative)  : CGeneralizedBlackScholesProcess(CVegaStressedBlackScholesProcess::typeid)
{
	_phVegaStressedBlackScholesProcess = &childNative;
	_ppVegaStressedBlackScholesProcess = &static_cast<boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess>>(childNative.currentLink());
    _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppVegaStressedBlackScholesProcess));
}
#endif
#ifdef STRUCT
Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::CVegaStressedBlackScholesProcess (QuantLib::VegaStressedBlackScholesProcess childNative)  : CGeneralizedBlackScholesProcess(CVegaStressedBlackScholesProcess::typeid)
{
#ifdef HANDLE
	_phVegaStressedBlackScholesProcess = NULL;
#endif
	_ppVegaStressedBlackScholesProcess = new boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess> (new QuantLib::VegaStressedBlackScholesProcess (childNative));
    _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppVegaStressedBlackScholesProcess));
}
#endif

Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::~CVegaStressedBlackScholesProcess ()
{
    if (_ppVegaStressedBlackScholesProcess != NULL)
    {
	    delete _ppVegaStressedBlackScholesProcess;
        _ppVegaStressedBlackScholesProcess = NULL;
    }
}
Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::!CVegaStressedBlackScholesProcess ()
{
    if (_ppVegaStressedBlackScholesProcess != NULL)
    {
	    delete _ppVegaStressedBlackScholesProcess;
    }
}
QuantLib::VegaStressedBlackScholesProcess& Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::GetReference ()
{
    if (_ppVegaStressedBlackScholesProcess == NULL) throw REFNEW NativeNullException ();
	return **_ppVegaStressedBlackScholesProcess;
}
boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess>& Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::GetShared ()
{
    if (_ppVegaStressedBlackScholesProcess == NULL) throw REFNEW NativeNullException ();
	return *_ppVegaStressedBlackScholesProcess;
}
QuantLib::VegaStressedBlackScholesProcess* Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::GetPointer ()
{
    if (_ppVegaStressedBlackScholesProcess == NULL) throw REFNEW NativeNullException ();
	return &**_ppVegaStressedBlackScholesProcess;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::VegaStressedBlackScholesProcess>& Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::GetHandle ()
{
	if (_phVegaStressedBlackScholesProcess == NULL)
	{
		_phVegaStressedBlackScholesProcess = new Handle<QuantLib::VegaStressedBlackScholesProcess> (*_ppVegaStressedBlackScholesProcess);
	}
	return *_phVegaStressedBlackScholesProcess;
}
#endif
bool Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::HasNative () 
{
	return (_ppVegaStressedBlackScholesProcess != NULL);
}

Double Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::Diffusion (Double t, Double x)
{
    try
    {
        QuantLib::Time _t = (QuantLib::Time)ValueHelper::Convert (t); //a
        QuantLib::Real _x = (QuantLib::Real)ValueHelper::Convert (x); //a
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppVegaStressedBlackScholesProcess)->diffusion ( _t,  _x );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::GetLowerAssetBorderForStressTest::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppVegaStressedBlackScholesProcess)->getLowerAssetBorderForStressTest ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::GetLowerTimeBorderForStressTest::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppVegaStressedBlackScholesProcess)->getLowerTimeBorderForStressTest ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::GetStressLevel::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppVegaStressedBlackScholesProcess)->getStressLevel ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::GetUpperAssetBorderForStressTest::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppVegaStressedBlackScholesProcess)->getUpperAssetBorderForStressTest ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::GetUpperTimeBorderForStressTest::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppVegaStressedBlackScholesProcess)->getUpperTimeBorderForStressTest ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^ Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::SetLowerAssetBorderForStressTest (Double LAB)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Real _LAB = (QuantLib::Real)ValueHelper::Convert (LAB); //a
    	(*_ppVegaStressedBlackScholesProcess)->setLowerAssetBorderForStressTest ( _LAB );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^ Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::SetLowerTimeBorderForStressTest (Double LTB)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Time _LTB = (QuantLib::Time)ValueHelper::Convert (LTB); //a
    	(*_ppVegaStressedBlackScholesProcess)->setLowerTimeBorderForStressTest ( _LTB );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^ Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::SetStressLevel (Double SL)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Real _SL = (QuantLib::Real)ValueHelper::Convert (SL); //a
    	(*_ppVegaStressedBlackScholesProcess)->setStressLevel ( _SL );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^ Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::SetUpperAssetBorderForStressTest (Double UBA)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Real _UBA = (QuantLib::Real)ValueHelper::Convert (UBA); //a
    	(*_ppVegaStressedBlackScholesProcess)->setUpperAssetBorderForStressTest ( _UBA );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^ Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess::SetUpperTimeBorderForStressTest (Double UTB)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Time _UTB = (QuantLib::Time)ValueHelper::Convert (UTB); //a
    	(*_ppVegaStressedBlackScholesProcess)->setUpperTimeBorderForStressTest ( _UTB );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^ Cephei::QL::Experimental::Processes::CVegaStressedBlackScholesProcess_Factory::Create (Cephei::QL::IQuote^ x0, Cephei::QL::Termstructures::IYieldTermStructure^ dividendTS, Cephei::QL::Termstructures::IYieldTermStructure^ riskFreeTS, Cephei::QL::Termstructures::Volatility::Equityfx::IBlackVolTermStructure^ blackVolTS, Microsoft::FSharp::Core::FSharpOption<Double>^ lowerTimeBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ upperTimeBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ lowerAssetBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ upperAssetBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ stressLevel)
{
    return REFNEW CVegaStressedBlackScholesProcess ( x0,  dividendTS,  riskFreeTS,  blackVolTS,  lowerTimeBorderForStressTest,  upperTimeBorderForStressTest,  lowerAssetBorderForStressTest,  upperAssetBorderForStressTest,  stressLevel);
}
